const fs = require('fs');
const path = require('path');

// 创建目标目录
const iconsDir = path.join(__dirname, '../assets/images/icons');
if (!fs.existsSync(iconsDir)) {
  fs.mkdirSync(iconsDir, { recursive: true });
}

// 创建TabBar图标目录
const tabbarDir = path.join(__dirname, '../assets/images/tabbar');
if (!fs.existsSync(tabbarDir)) {
  fs.mkdirSync(tabbarDir, { recursive: true });
}

// 定义要创建的图标
const icons = [
  'funeral-urn',
  'burial-clothes',
  'funeral-flowers',
  'memorial-items',
  'funeral',
  'legal',
  'transport',
  'memorial'
];

// 定义要创建的TabBar图标
const tabbarIcons = [
  { name: 'home', activeColor: '#ff6b00', inactiveColor: '#999' },
  { name: 'category', activeColor: '#ff6b00', inactiveColor: '#999' },
  { name: 'ai-inquiry', activeColor: '#ff6b00', inactiveColor: '#999' },
  { name: 'cart', activeColor: '#ff6b00', inactiveColor: '#999' },
  { name: 'profile', activeColor: '#ff6b00', inactiveColor: '#999' }
];

// 创建简单的占位SVG图标
function createPlaceholderIcon(name, color) {
  const svgContent = `<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
  <circle cx="50" cy="50" r="50" fill="${color || '#cccccc'}"/>
  <text x="50" y="50" font-family="Arial" font-size="16" fill="white" text-anchor="middle" dominant-baseline="middle">${name}</text>
</svg>`;

  fs.writeFileSync(path.join(iconsDir, `${name}.svg`), svgContent);
  console.log(`Created placeholder icon: ${name}.svg`);
}

// 创建TabBar图标
function createTabbarIcon(name, color) {
  const svgContent = `<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">
  <rect width="24" height="24" fill="transparent"/>
  <text x="12" y="12" font-family="Arial" font-size="10" fill="${color}" text-anchor="middle" dominant-baseline="middle">${name}</text>
</svg>`;

  return svgContent;
}

// 创建所有图标
icons.forEach((name, index) => {
  // 使用不同的颜色
  const colors = ['#D4A76A', '#7986CB', '#81C784', '#FF8A65', '#9575CD', '#4FC3F7', '#FFD54F', '#4DB6AC'];
  createPlaceholderIcon(name, colors[index % colors.length]);
});

// 创建所有TabBar图标
tabbarIcons.forEach(icon => {
  // 创建默认图标
  const inactiveSvg = createTabbarIcon(icon.name, icon.inactiveColor);
  fs.writeFileSync(path.join(tabbarDir, `${icon.name}.png`), Buffer.from(inactiveSvg));
  
  // 创建激活状态图标
  const activeSvg = createTabbarIcon(icon.name, icon.activeColor);
  fs.writeFileSync(path.join(tabbarDir, `${icon.name}-active.png`), Buffer.from(activeSvg));
  
  console.log(`Created tabbar icons: ${icon.name}.png and ${icon.name}-active.png`);
});

console.log('All placeholder icons created successfully!');
console.log(`Icons saved to: ${iconsDir}`);
console.log(`TabBar icons saved to: ${tabbarDir}`);
console.log('注意：这些只是占位图标，建议在实际项目中替换为真实图标。'); 